package com.controller;

import com.bean.User;
import com.dao.UserMapper;
import org.springframework.stereotype.Controller;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
@ContextConfiguration("classpath:springmvc.xml")
public class UserController {
    @Resource(name = "userMapper")
    private UserMapper userMapper;

    @RequestMapping("/login")
    public String checklogin(Model model, User user) {
        User user1 = userMapper.checklogin(user);
        if (user1 != null) {
            System.out.println(user1.toString());
            return "main";
        } else {
            model.addAttribute("msg", "登录失败");
            return "index";
        }
    }
}
